<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理后台 - 商品管理</title>
    <link rel="stylesheet" href="./css/houtai.css">
    <link rel="stylesheet" href="./css/houtai_product.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
    <div class="wrapper">
        <!-- 侧边栏 -->
        <aside class="sidebar">
            <div class="logo">
                <h2>超市管理系统</h2>
            </div>
            <ul class="menu">
                <li><a href="./houtai_gzt.html" class="menuItem"><i class="fas fa-tachometer-alt"></i><span>工作台</span></a></li>
                <li><a href="./houtai_user.html" class="menuItem"><i class="fas fa-users"></i><span>用户管理</span></a></li>
                <li><a href="./houtai_product.html" class="menuItem active"><i class="fas fa-box"></i><span>商品管理</span></a></li>
                <li><a href="./houtai_order.html" class="menuItem"><i class="fas fa-shopping-cart"></i><span>订单管理</span></a></li>
                <li><a href="./houtai_stock.html" class="menuItem"><i class="fas fa-warehouse"></i><span>库存管理</span></a></li>
                <li><a href="./houtai_log.html" class="menuItem"><i class="fas fa-history"></i><span>日志管理</span></a></li>
            </ul>
        </aside>

        <!-- 主体部分 -->
        <main class="main-content">
            <header class="header">
                <a id="collapse" href="javascript:void(0)">
                    <i class="fas fa-bars"></i>
                </a>
                <div class="header-title">商品管理</div>
                <div class="user-info">
                    <span id="username">欢迎，管理员</span>
                    <button id="logoutBtn" class="btn-logout">退出</button>
                </div>
            </header>

            <!-- 搜索和分类区域 -->
            <div class="content-area">
                <div class="product-section">
                    <div class="product-header">
                        <div class="header-right">
                            <div class="search-form">
                                <select id="categorySelect" class="form-control category-select">
                                    <option value="">全部分类</option>
                                </select>
                                <input type="text" id="searchName" class="form-control" placeholder="搜索商品名称">
                                <button class="btn btn-primary" id="searchBtn">
                                    <i class="fas fa-search"></i> 搜索
                                </button>
                                <button class="btn btn-secondary" id="resetBtn">
                                    <i class="fas fa-undo"></i> 重置
                                </button>
                                <button class="btn btn-success" id="addBtn">
                                    <i class="fas fa-plus"></i> 新增商品
                                </button>
                            </div>
                        </div>
                    </div>
                    
                    <!-- 商品列表 -->
                    <div class="product-grid">
                        <!-- 商品将通过JavaScript动态加载 -->
                    </div>
                </div>
            </div>
        </main>
    </div>

    <!-- 商品表单模态框 -->
    <div class="modal fade" id="productModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">商品信息</h5>
                    <button type="button" class="close" data-dismiss="modal">
                        <span>&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form id="productForm">
                        <input type="hidden" id="productId">
                        <div class="form-group">
                            <label for="categorySelect">商品分类</label>
                            <select class="form-control" id="modalCategorySelect" required>
                                <!-- 分类选项将通过JavaScript动态加载 -->
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="name">商品名称</label>
                            <input type="text" class="form-control" id="name" required>
                        </div>
                        <div class="form-group">
                            <label for="price">商品价格</label>
                            <input type="number" class="form-control" id="price" step="0.01" min="0" required>
                        </div>
                        <div class="form-group">
                            <label for="stock">库存数量</label>
                            <input type="number" class="form-control" id="stock" min="0" required>
                        </div>
                        <div class="form-group">
                            <label for="description">商品描述</label>
                            <textarea class="form-control" id="description" rows="3"></textarea>
                        </div>
                        <div class="form-group">
                            <label for="status">商品状态</label>
                            <select class="form-control" id="status">
                                <option value="1">上架</option>
                                <option value="0">下架</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>商品图片</label>
                            <input type="hidden" id="imageUrl">
                            <div id="uploadArea" class="upload-area">
                                <div class="upload-icon">
                                    <i class="fas fa-cloud-upload-alt"></i>
                                </div>
                                <div class="upload-text">点击或拖拽图片到此处上传</div>
                                <div class="upload-tip">支持jpg、png格式，文件大小不能超过5MB</div>
                            </div>
                            <input type="file" id="imageFile" class="file-input" accept="image/*">
                            <div class="preview-container" style="display: none;">
                                <img id="imagePreview" src="" alt="预览图">
                                <button type="button" id="removeImage" class="btn-remove">
                                    <i class="fas fa-times"></i>
                                </button>
                            </div>
                            <div class="upload-progress" style="display: none;">
                                <div class="progress-bar"></div>
                                <div class="progress-text">0%</div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="saveBtn">保存</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
    <script src="./js/houtai.js"></script>
    <script src="./js/houtai_product.js"></script>
</body>
</html>